package com.topone.permission.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import com.topone.permission.dao.PermissionMapper;
import com.topone.permission.entity.Permission;



@Service
public class PermissionService {
	
	@Autowired
	PermissionMapper permissionMapper;
	
	public void batchsave(List<Permission> list){
		Assert.notEmpty(list, "The Permission list is empty");
		permissionMapper.batchsave(list);
	}

	//获取所有非特权权限
	public List<Permission> getPermission(){
		return permissionMapper.getPermission();
	}
	
	public List<Permission> getAll(){
		return permissionMapper.getAll();
	}
	
	
		//通过roleId获取权限
	public List<Permission> findByRoleId(Long roleId){
		Assert.notNull(roleId,"RoleId is null");
		return permissionMapper.findByRoleId(roleId);
	}
		
		//通过userId获取所有权限
	public List<Permission> getPermissionByUserId(Long userId){
		Assert.notNull(userId,"userId is null");
		return permissionMapper.getPermissionByUserId(userId);
	}

	public List<Permission> findAll() {
		return permissionMapper.getAll();
	}
	
}
